<template>
	<view>
		<view-grid ref="grid" :index="true" :options="options">
			<!-- 自定义slot -->
			<view @click="viewClick" slot="gridHeader" class="grid-header">
				{{ gridHeaderText }}
			</view>
		</view-grid>
	</view>
</template>

<script>
//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
import extend from './q_goods_inventory_warehouse_xmExtend.js';
import options from './q_goods_inventory_warehouse_xmOptions.js';
export default {
	data() {
		let _options = options();
		_options.extend = extend;
		return {
			gridHeaderText: '', //随便输入字符后可以显示出来
			options: _options,
			time: null
		};
	},
	onShow() {
		console.log("uni.getStorageSync('WHSE_no')", uni.getStorageSync('WHSE_no'));
		let pages = getCurrentPages();
		let prevPage = pages[pages.length - 2];
		if (uni.getStorageSync('WHSE_no') && prevPage.route == 'pages/addPage/addPage') {
			this.time = setInterval(() => {
				if (this.$refs.grid) {
					console.log('定时器');
					clearInterval(this.time);
					this.$refs.grid.searchFormFields.库位 =uni.getStorageSync('WHSE_no')?JSON.parse(uni.getStorageSync('WHSE_no')):'';
					this.$refs.grid.searchFormOptions.forEach((item) => {
						if (item.field == '库位') {
							item.disabled = true;
						}
					});
					this.$refs.grid.refresh();
				}
			}, 500);
		}
	},
	onHide() {
		clearInterval(this.time);
	},
	methods: {
		viewClick() {
			//获取生成页面grid的对象
			console.log(this.$refs.grid.searchFormFields);
		}
	}
};
</script>

<style></style>
